home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsIImage.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  283 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIImage_h___
  39. #define nsIImage_h___
  40.  
  41. #include "nsISupports.h"
  42. #include "nsIRenderingContext.h"
  43. #include "nsRect.h"
  44.  
  45. class nsIDeviceContext;
  46.  
  47. struct nsColorMap
  48. {
  49.   //I lifted this from the image lib. The difference is that
  50.   //this uses nscolor instead of NI_RGB. Multiple color pollution
  51.   //is a bad thing. MMP
  52.   PRInt32 NumColors;  // Number of colors in the colormap.
  53.                       // A negative value can be used to denote a
  54.                       // possibly non-unique set.
  55.   //nscolor *Map;       // Colormap colors.
  56.   PRUint8 *Index;     // NULL, if map is in index order, otherwise
  57.                       // specifies the indices of the map entries. */
  58. };
  59.  
  60. typedef enum {
  61.     nsMaskRequirements_kNoMask,
  62.     nsMaskRequirements_kNeeds1Bit,
  63.     nsMaskRequirements_kNeeds8Bit
  64. } nsMaskRequirements;
  65.  
  66.  
  67. #define  nsImageUpdateFlags_kColorMapChanged 0x1
  68. #define  nsImageUpdateFlags_kBitsChanged     0x2
  69.  
  70. // The following platforms store image data rows bottom-up.
  71. #if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX)
  72. #define MOZ_PLATFORM_IMAGES_BOTTOM_TO_TOP
  73. #endif
  74.  
  75. // IID for the nsIImage interface
  76. #define NS_IIMAGE_IID          \
  77.   { 0xce91c93f, 0x532d, 0x470d, \
  78.       { 0xbf, 0xa3, 0xc9, 0x6e, 0x56, 0x01, 0x52, 0xa4 } }
  79.  
  80. // Interface to Images
  81. class nsIImage : public nsISupports
  82. {
  83.  
  84. public:
  85.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGE_IID)
  86.  
  87.   /**
  88.    * Build and initialize the nsIImage
  89.    * @param aWidth The width in pixels of the desired pixelmap
  90.    * @param aHeight The height in pixels of the desired pixelmap
  91.    * @param aDepth The number of bits per pixel for the pixelmap
  92.    * @param aMaskRequirements A flag indicating if a alpha mask should be allocated 
  93.    */
  94.   virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
  95.  
  96.   /**
  97.    * Get the number of bytes per pixel for this image
  98.    * @update - dwc 2/3/99
  99.    * @return - the number of bytes per pixel
  100.    */
  101.   virtual PRInt32 GetBytesPix() = 0;
  102.  
  103.   /**
  104.    * Get whether rows are organized top to bottom, or bottom to top 
  105.    * @update - syd 3/29/99 
  106.    * @return PR_TRUE if top to bottom, else PR_FALSE 
  107.    */
  108.   virtual PRBool GetIsRowOrderTopToBottom() = 0;
  109.  
  110.   /**
  111.    * Get the width for the pixelmap
  112.    * @update - dwc 2/1/99
  113.    * @return The width in pixels for the pixelmap
  114.    */
  115.   virtual PRInt32 GetWidth() = 0;
  116.  
  117.   /**
  118.    * Get the height for the pixelmap
  119.    * @update - dwc 2/1/99
  120.    * @return The height in pixels for the pixelmap
  121.    */
  122.   virtual PRInt32 GetHeight() = 0;
  123.  
  124.   /**
  125.    * Get a pointer to the bits for the pixelmap, only if it is not optimized
  126.    * @update - dwc 2/1/99
  127.    * @return address of the DIB pixel array
  128.    */
  129.   virtual PRUint8 * GetBits() = 0;
  130.  
  131.   /**
  132.    * Get the number of bytes needed to get to the next scanline for the pixelmap
  133.    * @update - dwc 2/1/99
  134.    * @return The number of bytes in each scanline
  135.    */
  136.   virtual PRInt32 GetLineStride() = 0;
  137.  
  138.   /**
  139.    * Get whether this image has an alpha mask. Preferable to testing
  140.    * if GetAlphaBits() is non-null.
  141.    * @update - sfraser 10/19/99
  142.    * @return PR_TRUE if the image has an alpha mask, PR_FALSE otherwise
  143.    */
  144.   virtual PRBool GetHasAlphaMask() = 0;
  145.  
  146.   /**
  147.    * Get a pointer to the bits for the alpha mask
  148.    * @update - dwc 2/1/99
  149.    * @return address of the alpha mask pixel array
  150.    */
  151.   virtual PRUint8 * GetAlphaBits() = 0;
  152.  
  153.   /**
  154.    * Get the number of bytes per scanline for the alpha mask
  155.    * @update - dwc 2/1/99
  156.    * @return The number of bytes in each scanline
  157.    */
  158.   virtual PRInt32 GetAlphaLineStride() = 0;
  159.  
  160.   /**
  161.    * Update the nsIImage color table
  162.    * @update - dwc 2/1/99
  163.    * @param aFlags Used to pass in parameters for the update
  164.    * @param aUpdateRect The rectangle to update
  165.    */
  166.   virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect) = 0;
  167.   
  168.   /**
  169.    * Get whether this image's region is completely filled with data.
  170.    * @return PR_TRUE if image is complete, PR_FALSE if image is not yet 
  171.    *         complete or broken
  172.    */
  173.   virtual PRBool GetIsImageComplete() = 0;
  174.  
  175.   /**
  176.    * Converted this pixelmap to an optimized pixelmap for the device
  177.    * @update - dwc 2/1/99
  178.    * @param aContext The device to optimize for
  179.    * @return the result of the operation, if NS_OK, then the pixelmap is optimized
  180.    */
  181.   virtual nsresult Optimize(nsIDeviceContext* aContext) = 0;
  182.  
  183.   /**
  184.    * Get the colormap for the nsIImage
  185.    * @update - dwc 2/1/99
  186.    * @return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
  187.    */
  188.   virtual nsColorMap * GetColorMap() = 0;
  189.  
  190.   /**
  191.    * BitBlit the nsIImage to a device, the source can be scaled to the dest
  192.    * @update - dwc 2/1/99
  193.    * @param aSurface  the surface to blit to
  194.    * @param aX The destination horizontal location
  195.    * @param aY The destination vertical location
  196.    * @param aWidth The destination width of the pixelmap
  197.    * @param aHeight The destination height of the pixelmap
  198.    * @return if TRUE, no errors
  199.    */
  200.   NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
  201.  
  202.   /**
  203.    * BitBlit the nsIImage to a device, the source and dest can be scaled
  204.    * @update - dwc 2/1/99
  205.    * @param aSurface  the surface to blit to
  206.    * @param aSX The source width of the pixelmap
  207.    * @param aSY The source vertical location
  208.    * @param aSWidth The source width of the pixelmap
  209.    * @param aSHeight The source height of the pixelmap
  210.    * @param aDX The destination horizontal location
  211.    * @param aDY The destination vertical location
  212.    * @param aDWidth The destination width of the pixelmap
  213.    * @param aDHeight The destination height of the pixelmap
  214.    * @return if TRUE, no errors
  215.    */
  216.   NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface,
  217.                   PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
  218.                   PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
  219.  
  220.  
  221.   NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
  222.                       nsIDrawingSurface* aSurface,
  223.                       PRInt32 aSXOffset, PRInt32 aSYOffset,
  224.                       PRInt32 aPadX, PRInt32 aPadY,
  225.                       const nsRect &aTileRect) = 0;
  226.  
  227.   /**
  228.    * BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
  229.    * @update - saari 03/08/01
  230.    * @param aDstImage  the nsImage to blit to
  231.    * @param aDX The destination horizontal location
  232.    * @param aDY The destination vertical location
  233.    * @param aDWidth The destination width of the pixelmap
  234.    * @param aDHeight The destination height of the pixelmap
  235.    * @return if TRUE, no errors
  236.    */
  237.   NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
  238.  
  239.   /**
  240.    * Get the alpha depth for the image mask
  241.    * @update - lordpixel 2001/05/16
  242.    * @return  the alpha mask depth for the image, ie, 0, 1 or 8
  243.    */
  244.   virtual PRInt8 GetAlphaDepth() = 0;
  245.  
  246.   /**
  247.    * Return information about the bits for this structure
  248.    * @update - dwc 2/1/99
  249.    * @return a bitmap info structure for the Device Dependent Bits
  250.    */
  251.   virtual void* GetBitInfo() = 0;
  252.  
  253.  
  254.   /**
  255.    * LockImagePixels
  256.    * Lock the image pixels so that we can access them directly,
  257.    * with safely. May be a noop on some platforms.
  258.    *
  259.    * aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
  260.    *
  261.    * Must be balanced by a call to UnlockImagePixels().
  262.    *
  263.    * @update - sfraser 10/18/99
  264.    * @return error result
  265.    */
  266.   NS_IMETHOD LockImagePixels(PRBool aMaskPixels) = 0;
  267.   
  268.   /**
  269.    * UnlockImagePixels
  270.    * Unlock the image pixels. May be a noop on some platforms.
  271.    *
  272.    * Should balance an earlier call to LockImagePixels().
  273.    *
  274.    * aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
  275.    *
  276.    * @update - sfraser 10/18/99
  277.    * @return error result
  278.    */
  279.   NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels) = 0;
  280. };
  281.  
  282. #endif
  283.